package myJs.myPkg.contextMenu

import japgolly.scalajs.react.CtorType.ChildArg
import japgolly.scalajs.react.{Children, JsFnComponent}
import slinky.readwrite.ObjectOrWritten

import scala.scalajs.js
import scala.scalajs.js.annotation.JSImport

/** Created by yz on 7/2/2022
  */

@js.native
@JSImport("react-contextmenu", name = JSImport.Default)
object ReactContextMenu extends js.Object {

  def hideMenu(): Unit = js.native

}

object ContextMenu{

  case class Props(
      id: String
  )

  @js.native
  @JSImport("react-contextmenu", "ContextMenu")
  object RawComponent extends js.Object {}

  val Component = JsFnComponent[ObjectOrWritten[Props], Children.Varargs](RawComponent)

  def apply(
    id: String
  )(children: ChildArg*) = {
    Component(Props(id))(children: _*)
  }

}
